Skip to content

FOUR-8217: Automate Default Template Creations#4784

Merged
ryancooley merged 47 commits into
developfrom
template-sync
Jul 21, 2023
Merged

FOUR-8217: Automate Default Template Creations#4784
ryancooley merged 47 commits into
developfrom
template-sync

Conversation

@ryancooley
Copy link
Copy Markdown
Contributor

@ryancooley ryancooley commented May 15, 2023

Issue & Reproduction Steps

In the current workflow, updating or adding default templates on a server requires manual intervention, significantly impacting engineers' development time. This PR aims to address this issue by introducing an automated process for updating and creating default templates.

Solution

To achieve this, the following key changes have been implemented:

  • Creation of a new artisan command, php artisan processmaker:sync-default-templates, which triggers the SyncDefaultTemplates job. This job retrieves the index.json data from the Process Templates Repo.
  • The artisan command also incorporates the --queue flag, allowing the job to run on a daily schedule at a random time. This ensures regular synchronization without manual intervention.
  • Removal of existing seeded default process templates, which are then replaced with the templates from the Process Templates Repo.

How to Configure:

To successfully configure the automated default template synchronization, follow these steps:

  1. Open your .env file for your project.
  2. Add the following new variables and their respective values:
  • DEFAULT_TEMPLATE_REPO=process-templates
    Set the value for this variable as the name of the process-templates repository that contains the templates you want to
    sync with your environment.

  • DEFAULT_TEMPLATE_BRANCH=develop
    Set the value for this variable as the name of the branch in the process-templates repository that contains the desired
    templates for your environment.

  • DEFAULT_TEMPLATE_CATEGORIES=all
    This variable allows you to specify specific verticals (directories) in the process-templates repository to be synced with
    your environment. By default, it is set to all, which means all directories in the develop branch will be synced.

    To specify a single directory, set the value to the directory name. For example, to sync the 'banking' directory in the
    process- templates repository, set DEFAULT_TEMPLATE_CATEGORIES=banking

    To sync multiple directories, separate the names with a comma.
    For example: DEFAULT_TEMPLATE_CATEGORIES=banking,human-resources,financing

  1. Save the changes to your .env file.
  2. Run php artisan optimize:clear

ci:package-data-sources:template-sync

ci:deploy

How to Test

Test Case A: Remove seeded Template and Sync with GitHub

  1. Edit an existing default template, such as the New Hire Onboarding template, to become the owner of the template.
  2. Run php artisan migrate to trigger the migrations that remove the seeded default templates and synchronize the existing templates in the Process Templates GitHub repo.
  3. Verify that the New Hire Onboarding template does not have duplicates and contains the changes you made.

Test Case B: Fresh install

  1. Ensure you have a backup of the data you want to keep.
  2. Wipe your database by running php artisan db:wipe --force && php artisan migrate:fresh --seed --force.
  3. Run php artisan processmaker:sync-default-templates.
  4. Verify that the GitHub repos are synced under the Templates tab.

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

@sanjacornelius sanjacornelius changed the title Template sync proof of concept WIP FOUR-8217: Automate Default Template Creations May 17, 2023
@sanjacornelius sanjacornelius marked this pull request as ready for review May 17, 2023 17:49
Copy link
Copy Markdown
Contributor

@mcraeteisha mcraeteisha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved!

@tokensPM
Copy link
Copy Markdown

QA server was successfully deployed https://ci-d5fd13766f.eng.processmaker.net

@processmaker-sonarqube
Copy link
Copy Markdown

@tokensPM
Copy link
Copy Markdown

QA server was successfully deployed https://ci-d5fd13766f.eng.processmaker.net

@ryancooley ryancooley merged commit 80a8a28 into develop Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants